package com.jeeplus.modules.sys.web;

import java.io.IOException;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.faces.validator.BeanValidator;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.validation.ConstraintViolationException;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.jeeplus.common.beanvalidator.BeanValidators;
import com.jeeplus.common.json.AjaxJson;
import com.jeeplus.common.json.ReturnJson;
import com.jeeplus.common.utils.ResponseCode;
import com.jeeplus.core.mapper.JsonMapper;
import com.jeeplus.core.persistence.Page;
import com.jeeplus.core.web.BaseController;
import com.jeeplus.modules.sys.entity.DataInterface;
import com.jeeplus.modules.sys.entity.Pagination;
import com.jeeplus.modules.sys.service.DataInterfaceService;
import org.apache.shiro.authz.annotation.Logical;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;

import com.google.common.collect.Lists;
import com.jeeplus.common.utils.DateUtils;
import com.jeeplus.common.utils.MyBeanUtils;
import com.jeeplus.common.config.Global;
import com.jeeplus.common.utils.StringUtils;
import com.jeeplus.common.utils.excel.ExportExcel;
import com.jeeplus.common.utils.excel.ImportExcel;

/**
 * @author Administrator
 * @title: DataInterfaceController
 * @projectName JeePlus
 * @description: TODO
 * @date 2019/11/1210:57
 */
@Controller
@RequestMapping(value = "${adminPath}/sys/datainterface/")
public class DataInterfaceController extends BaseController {
    @Autowired
    private DataInterfaceService dataInterfaceService;
    //region 视图功能
    /**
     * DataInterface列表页面
     */
    @RequiresPermissions("datainterface:datainterface:dataInterface:list")
    @RequestMapping(value = {"list", ""})
    public String list(DataInterface dataInterface, HttpServletRequest request, HttpServletResponse response) {
        return "modules/sys/datainterface/dataInterfaceList";
    }
    @RequestMapping(value = "Form")
    public String Form(DataInterface dataInterface, Model model){
        DataInterface dataInterface1=new DataInterface();
        model.addAttribute("dataInterface", dataInterface1);
        return "modules/sys/datainterface/dataInterfaceForm";
    }
    //endregion
    //region 数据功能
    @RequestMapping(value = "GetPageList")
    @ResponseBody
    public Object GetPageList(String queryJson , HttpServletRequest request, HttpServletResponse response) throws IOException {
        System.out.println(queryJson);
        String pagination=request.getParameter("pagination");
        Pagination paginationobj = JSONObject.toJavaObject(JSONObject.parseObject(pagination),Pagination.class);
        Pagination JsonData=dataInterfaceService.GetPageList(paginationobj);
        return reportSuccess(JsonData);
    }
    @RequestMapping(value = "SaveForm")
    @ResponseBody
    public ReturnJson SaveForm(HttpServletRequest request,String strEntity){
        ReturnJson returnJson=new ReturnJson();
        System.out.println(request.getParameter("keyValue"));
        System.out.println(request.getParameter("strEntity"));
        System.out.println(strEntity);
        return returnJson;
    }
    //endregion
}
